package kaoshi;

public class Quest6 {
    public static void main(String[] args) {
        System.out.println(fi(5));
    }

    public static int fi(int n) {
        int a[] = new int[4];
        a[1]=a[2]=a[0]=1;
        for (int i = 3 ;i<n;i++){
            a[3]=a[0]+a[1]*3+2*a[2];
            a[0]=a[1];
            a[1]=a[2];
            a[2]=a[3];
        }
        return a[2];
    }
}
